import { Component } from '@angular/core';
import { Camera } from '@ionic-native/camera';


@Component({
    selector: 'page-camera',
    templateUrl: 'camera.html'
})
export class CameraPage {
    base64Image:any;
    result:any;
    constructor(
        private camera: Camera
    ){
        var options = {  
            quality: 100,  
            destinationType: this.camera.DestinationType.DATA_URL,  
            sourceType: this.camera.PictureSourceType.CAMERA,  
            allowEdit: false,  
            targetHeight: 200,
            targetWidth: 200,
            encodingType: this.camera.EncodingType.PNG,   
            saveToPhotoAlbum: false  
        }; 
        this.camera.getPicture(options).then((imageData) => {
            // imageData is either a base64 encoded string or a file URI
            // If it's base64:
            this.base64Image = 'data:image/png;base64,' + imageData;
            console.log(this.base64Image);
        }, (err) => {
            console.log(err);
        });
    }
}